import 'package:flutter/material.dart';
import 'package:xbxxz_assistant/mine/mine_page.dart';
import 'package:xbxxz_assistant/steal_map/calculator_page.dart';
import 'package:xbxxz_assistant/strategy/strategy_page.dart';

class HomePage extends StatefulWidget {
  @override
  _HomePageState createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
  int _selectedIndex = 0;
  final _widgetItems = [CalculatorPage(), StrategyPage(), MinePage()];

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(
          "想不想修真助手",
          style: TextStyle(color: Colors.black45),
        ),
      ),
      body: Container(
        color: Colors.brown,
        child: _widgetItems[_selectedIndex],
      ),
      bottomNavigationBar: BottomNavigationBar(
        backgroundColor: Colors.brown,
        currentIndex: _selectedIndex,
        selectedItemColor: Color.fromRGBO(220, 200, 160, 1.0),
        onTap: _onBarItem,
        items: [
          BottomNavigationBarItem(
            title: Text("计算器"),
            icon: Icon(Icons.person),
          ),
          BottomNavigationBarItem(
            title: Text("攻略"),
            icon: Icon(Icons.person),
          ),
          BottomNavigationBarItem(
            title: Text("我的"),
            icon: Icon(Icons.computer),
          ),
        ],
      ),
      resizeToAvoidBottomPadding: false,
    );
  }

  void _onBarItem(int index) {
    setState(() {
      _selectedIndex = index; //刷新界面
    });
  }
}
